/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package action.retail;

import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import com.opensymphony.xwork2.validator.annotations.FieldExpressionValidator;
import com.opensymphony.xwork2.validator.annotations.RequiredStringValidator;
import com.opensymphony.xwork2.validator.annotations.StringLengthFieldValidator;
import com.opensymphony.xwork2.validator.annotations.VisitorFieldValidator;
import model.Customer;

/**
 *
 * @author Thai Ha Cong
 */
public class UpdateProfileAction extends ActionSupport implements ModelDriven<Customer>{
    
    private Customer customer = new Customer();
//    private String username;
    private String oldpassword;
    private String newpassword;
    private String confirmPassword;
    
    public UpdateProfileAction() {
    }

    public Customer getCustomer() {
        return customer;
    }

    public void setCustomer(Customer customer) {
        this.customer = customer;
    }

    public String getOldpassword() {
        return oldpassword;
    }

    @RequiredStringValidator(message = "Old Password is required.")
    public void setOldpassword(String oldpassword) {
        this.oldpassword = oldpassword;
    }

    public String getNewpassword() {
        return newpassword;
    }

    @RequiredStringValidator(message = "New Password is required.")
    @StringLengthFieldValidator(message = "New Password should contains 6-30 characters.", minLength = "6", maxLength = "30")
    public void setNewpassword(String newpassword) {
        this.newpassword = newpassword;
    }

    public String getConfirmPassword() {
        return confirmPassword;
    }

    @FieldExpressionValidator(expression = "confirmPassword==newpassword", message = "Passwords do not match.")
    public void setConfirmPassword(String confirmPassword) {
        this.confirmPassword = confirmPassword;
    }
    
    @Override
    public String execute() throws Exception {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    @VisitorFieldValidator(message = "", appendPrefix = false)
    public Customer getModel() {
        return customer;
    }
}